using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using Emlyn.Common.Data.DBUpdater;
using Emlyn.Common.Data.SqlServer.SqlManagers;
using Emlyn.Common.Data.Configuration;

public partial class EmlynOReganTitle : System.Web.UI.UserControl
{
    private string GetBaseUrl()
    {
        string lpath = Page.Request.Url.GetComponents(UriComponents.Path, UriFormat.UriEscaped);
        string[] lpathArr = lpath.Replace('\\', '/').Split('/');
        IList<string> lresultPath = new List<string>();
        string retval = String.Empty;

        foreach (string lpathSegment in lpathArr)
        {
            if (lpathSegment.ToUpper().Equals("SECURE"))
            {
                // do nothing
            }
            else if (lpathSegment.ToUpper().Contains(".ASPX"))
            {
                // do nothing
            }
            else
            {
                lresultPath.Add(lpathSegment);
            }
        }

        foreach (string lresultSegment in lresultPath)
        {
            if (retval.Length > 0)
                retval += "/";
            retval += lresultSegment;
        };


        if (retval.Length > 0)
            retval = Page.Request.Url.GetLeftPart(UriPartial.Authority) + "/" + retval;
        else
            retval = Page.Request.Url.GetLeftPart(UriPartial.Authority);

        return retval;
    }
    
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void btnMain_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect(GetBaseUrl());
    }

    protected void btnBlogs_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect(GetBaseUrl() + "/Blog.aspx");
    }

    protected void btnMusic_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect(GetBaseUrl() + "/Music.aspx");
    }

    protected void btnSoftware_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect(GetBaseUrl() + "/Software.aspx");
    }

    protected void btnWriting_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect(GetBaseUrl() + "/Writing.aspx");
    }

    protected void btnAboutme_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect(GetBaseUrl() + "/AboutMe.aspx");
    }
    protected void btnTitle_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect(GetBaseUrl());
    }
}
